﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication
{
    public partial class FindForm : Form
    {
        private char spliter = ',';
        public FindForm()
        {
            InitializeComponent();
        }

        private void btnFindIds_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtText1.Text) || string.IsNullOrEmpty(txtText2.Text))
            {
                MessageBox.Show("Please input ids!");
            }
            else
            {
                string[] list1 = txtText1.Text.Split(spliter);
                string[] list2 = txtText2.Text.Split(spliter);
                StringBuilder sb = new StringBuilder();
                foreach (var l1 in list1)
                {
                    foreach (var l2 in list2)
                    {
                        if (l1.Trim() == l2.Trim())
                        {
                            sb.Append(l1);
                            sb.Append(",");
                        }
                    }
                }
                if (sb.Length == 0)
                {
                    txtResult.Text = "No same ids";
                }
                else
                {
                    txtResult.Text = sb.ToString();
                }
            }
        }
    }
}
